<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script src="./node_modules/axios/dist/axios.js"></script>
  <script>
    axios({
      method: 'POST', // GraphQL 的请求方法必须是 POST
      url: 'http://localhost:4000/graphql',
      data: {
        query: `
          query getUserList {
            users {
              _id,
              username
              age
            }
          }
        `,
        // variables: {
        //   id: 2
        // }
      }
    }).then(res => {
      console.log(res.data)
    })

    const id = '6884d2d2a2b94f32b2418e7b'
    axios({
      method: 'POST', // GraphQL 的请求方法必须是 POST
      url: 'http://localhost:4000/graphql',
      data: {
        query: `
          query getUser($id: ID!) {
             user(id: $id) {
               _id
               username
             }
           }
        `,
        variables: {
          id: "6884d2d2a2b94f32b2418e7b"
        }
      }
    }).then(res => {
      console.log(res.data)
    })

  </script>
</body>
</html>
